using System.Web.Mvc;
using HooIzDat.Web.Models;
using HooIzDat.Web.Models.ViewModels;

namespace HooIzDat.Web.Controllers
{
    public class CharactersController : Controller
    {
        private ICharacterRepository characterRepository = new CharacterRepository();

        //
        // GET: /Characters/

        public ActionResult Index()
        {
            var characters = characterRepository.FindAllCharacters();
            return View(new CharacterIndexModel { Characters = characters });
        }

        //
        // GET: /Characters/Details/5

        public ActionResult Details(int id)
        {
            return View();
        }

        //
        // GET: /Characters/Create

        public ActionResult Create()
        {
            return View();
        } 

        //
        // POST: /Characters/Create

        [HttpPost]
        public ActionResult Create(FormCollection collection)
        {
            try
            {
                // TODO: Add insert logic here

                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }

        //
        // GET: /Characters/Edit/5
 
        public ActionResult Edit(int id)
        {
            return View();
        }

        //
        // POST: /Characters/Edit/5

        [HttpPost]
        public ActionResult Edit(int id, FormCollection collection)
        {
            try
            {
                // TODO: Add update logic here
 
                return RedirectToAction("Index");
            }
            catch
            {
                return View();
            }
        }
    }
}
